package com.kyzh.core.popup

import android.content.Context
import android.widget.EditText
import android.widget.TextView
import com.gushenge.core.toast
import com.hjq.shape.view.ShapeEditText
import com.hjq.shape.view.ShapeTextView
import com.kyzh.core.R
import com.lxj.xpopup.core.CenterPopupView
import org.jetbrains.anko.find

//
class CDKPopupWindow(context: Context, var callback: (str: String?) -> Unit?) : CenterPopupView(context) {

    private var mContent: EditText? = null
    private var tvCancel: TextView? = null
    private var tvConfirm: TextView? = null

    override fun getImplLayoutId() = R.layout.dialog_cdk_popup


    override fun onCreate() {
        super.onCreate()
        mContent = findViewById(R.id.edContent)
        tvCancel = findViewById(R.id.tvCancel)
        tvConfirm = findViewById(R.id.tv_confirm)
        tvCancel!!.setOnClickListener {
            this.dialog.dismiss()
        }
        tvConfirm!!.setOnClickListener {
            if (mContent!!.text.toString().trim().isNullOrEmpty()) {
                mContent!!.hint.toast()
                return@setOnClickListener
            }
            callback.invoke(mContent!!.text.toString().trim())
            this.dialog.dismiss()
        }
    }


}
